﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace VFCons
{
	public partial class FTCameraSeletion : UserControl
	{
		public FTCameraSeletion()
		{
			InitializeComponent();
			//labelBack.Text = "背部光源拍照" + Environment.NewLine + "亮度(6--999)(2mA)";
			//labelUp.Text = "顶部光源拍照" + Environment.NewLine + "亮度(6--999)(2mA)";
		}

		public bool CanChecked
		{
			get { return checkBoxBack.Enabled; }
			set { checkBoxBack.Enabled = value;checkBoxUp.Enabled = value; }
		}
		private ushort _brightBack = 0;
		public ushort BrightnessBack
		{
			get { return _brightBack; }
			set
			{
				_brightBack = value;
				textBoxLightBack.Text = (_brightBack).ToString();
			}
		}

		private ushort _brightUp = 0;
		public ushort BrightnessUp
		{
			get { return _brightUp; }
			set
			{
				_brightUp = value;
				textBoxLightUp.Text = (_brightUp).ToString();
			}
		}

		private int _exposureBack = 10;
		public int ExposureBack
		{
			get { return _exposureBack; }
			set { _exposureBack = value;textBoxExposureBack.Text = _exposureBack.ToString(); }
		}

		private int _exposureUp = 10;
		public int ExposureUp
		{
			get { return _exposureUp; }
			set { _exposureUp = value;textBoxExposureUP.Text = _exposureUp.ToString(); }
		}
		public bool EnabledUp
		{
			get { return checkBoxUp.Checked; }
			set { checkBoxUp.Checked = value;textBoxExposureUP.Enabled = value;textBoxLightUp.Enabled = value; }
		}

		public bool EnabledDown
		{
			get { return checkBoxBack.Checked; }
			set { checkBoxBack.Checked = value; textBoxExposureBack.Enabled = value;textBoxLightBack.Enabled = value; }
		}

		public bool UI2Data()
		{
			try
			{
				ushort u = Convert.ToUInt16(textBoxLightUp.Text);
				ushort d = Convert.ToUInt16(textBoxLightBack.Text);
				int eb = (int)Convert.ToUInt32(textBoxExposureBack.Text);
				int eu = (int)Convert.ToUInt32(textBoxExposureUP.Text);
				BrightnessUp = u;
				BrightnessBack = d;
				ExposureBack = eb;
				ExposureUp = eu;
				return true;
			}
			catch (Exception ex)
			{
				MessageBox.Show("FTCameraSelection.UI2Data" + Environment.NewLine + ex.Message, "ERROR");
				return false;
			}
		}
	}
}
